//
//  UIButton+Extension.swift
//  微博Swift
//
//  Created by apple on 15/9/22.
//  Copyright © 2015年 cc. All rights reserved.
//

import UIKit

/// UIButton分类
extension UIButton {
    
    /// 便利构造函数
    convenience init(imageName: String, backImageName: String){
        self.init()
        
        setImage(UIImage(named: imageName), forState: UIControlState.Normal)
        setImage(UIImage(named: imageName + "_highlighted"), forState: UIControlState.Highlighted)
        setBackgroundImage(UIImage(named: backImageName), forState: UIControlState.Normal)
        setBackgroundImage(UIImage(named: backImageName + "_highlighted"), forState: UIControlState.Highlighted)
        // 自动调整大小
        sizeToFit()
        
    }
    
    convenience init(backImageName: String, title: String,fontSize: CGFloat,color: UIColor) {
        self.init()
        
        setBackgroundImage(UIImage(named: backImageName), forState: UIControlState.Normal)
        setTitle(title, forState: UIControlState.Normal)
        titleLabel?.font = UIFont.systemFontOfSize(fontSize)
        setTitleColor(color, forState: UIControlState.Normal)
        
    }
    
    
}
